package com.example.service.Impl;

import com.example.mapper.TeacherMapper;
import com.example.mapper.UserMapper;
import com.example.pojo.Teacher;
import com.example.pojo.User;
import com.example.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private UserMapper userMapper;

    //添加
    @Override
    public void add(Teacher teacher) {
        teacherMapper.insertTeacher(teacher);

    }

    //根据id查询
    @Override
    public Teacher query(Integer id) {
        Teacher teacher = teacherMapper.queryById(id);
        return teacher;
    }

    //查询列表
    @Override
    public List<Teacher> list() {
        List<Teacher> teacherlist = teacherMapper.list();
        return teacherlist;
    }

    //根据姓名查询
    @Override
    public Teacher query(String teacherName) {
        Teacher teacher = teacherMapper.queryByName(teacherName);
        return  teacher;
    }
    //修改
    @Override
    public void update(Teacher teacher) {
        teacherMapper.updateTeacher(teacher);
    }
    //关联
    @Override
    public void connectUser(String teacherName) {
        teacherMapper.connectUser(teacherName);
    }
}
 